#include <bits/stdc++.h>
using namespace std;
struct ListNode{
    int val;
    struct ListNode* next;
};

vector<ListNode*> solve(int m, ListNode* a){
    
    vector<ListNode*> head(m);
    vector<ListNode*> end(m);

    ListNode* curr = a;
    while(curr){
        int cls = curr->val%m;
        if(head[cls]){
            end[cls]->next = curr;
            end[cls] = curr;
        }
        else{
            head[cls] = curr;
            end[cls] = head[cls];
        }
        curr = curr->next;
        end[cls]->next = nullptr;
    }

    return head;
}



int main(){





}